<template>
	<view class="columnbox wdh-100 content jus" :style="{'height':windowHeight+'px'}">
		<!-- <view class="wdh-100 tab-box">
            <u-tabs :current='current' :list="type" @click="changeTab"></u-tabs>
        </view> -->
		<template v-if="current==0">
			<view class="rowbox wdh-100 spb info-box">
				<scroll-view scroll-with-animation :scroll-into-view="ksscroll" scroll-y class="left-scroll">
					<view :id="'ks-'+index" @click="changeKs(index)" v-for="(item,index) in keshi" :key='index'
						class="rowbox one-box" :class="{'sel-info':index==curkeshi}">
						{{item.name}}
					</view>
				</scroll-view>
				<scroll-view scroll-y class="right-scroll">
					<template v-if="keshi.length>0&&keshi[curkeshi].List">
						<view @click="chooseItem('keshiid',item)" v-for="(item,index) in keshi[curkeshi].List"
							:key='index' class="rowbox one-box">
							{{item.name}}
						</view>
					</template>
				</scroll-view>
			</view>
		</template>
		<template v-else>
			<view class="rowbox wdh-100 spb info-box">
				<scroll-view scroll-with-animation :scroll-into-view="jbscroll" scroll-y class="left-scroll">
					<view :id="'jb-'+index" @click="changeJb(index)" v-for="(item,index) in jibing" :key='index'
						class="rowbox one-box" :class="{'sel-info':index==curjibing}">
						{{item.name}}
					</view>
				</scroll-view>
				<scroll-view scroll-y class="right-scroll">
					<template v-if="jibing.length>0&&jibing[curjibing].List">
						<view @click="chooseItem('jibingid',item)" v-for="(item,index) in jibing[curjibing].List"
							:key='index' class="rowbox one-box">
							{{item.name}}
						</view>
					</template>
				</scroll-view>
			</view>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				type: [{
						name: '按科室',
					},
					{
						name: '按疾病',
					}
				],
				current: 0,
				windowHeight: 0,
				jibing: [],
				curjibing: 0,
				jbscroll: 'jb-0',
				keshi: [],
				curkeshi: 0,
				ksscroll: 'ks-0'
			};
		},
		onLoad(options) {
			uni.getSystemInfo({
				success: (res) => {
					this.windowHeight = res.windowHeight
				}
			})
			if (options.type) {
				this.current = options.type * 1
			}
			this.getInfo()
		},
		methods: {
			chooseItem(type, v) {
				let pages = getCurrentPages(); //获取所有页面栈实例列表
				let nowPage = pages[pages.length - 1]; //当前页页面实例
				let prevPage = pages[pages.length - 2]; //上一页页面实例
				prevPage.$vm.keshi = v
				uni.navigateBack()
				// uni.navigateTo({
				//     url: `/pages/doctor/doctor?type=${type}&id=${v.id}&name=${v.name}`
				// })
			},
			changeJb(index) {
				this.jbscroll = 'jb-' + (index == 0 ? 0 : index - 1)
				this.curjibing = index
			},
			changeKs(index) {
				this.ksscroll = 'ks-' + (index == 0 ? 0 : index - 1)
				this.curkeshi = index
			},
			changeTab(e) {
				this.current = e.index
			},
			getInfo() {
				this.$req.post('/user/keshis').then(res => {
					this.keshi = res.data.data
				})
				// this.$req.post('/user/jibing').then(res => {
				//     this.jibing = res.data.data
				// })
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		font-family: PingFang SC;
	}

	.tab-box {
		background: #fff;
		border-bottom: #e2e4e4 solid 1px;
		height: 110rpx;
	}

	.info-box {
		height: 100%;
	}

	.left-scroll {
		height: 100%;
		width: 250rpx;
		background: #f8f9fb;
	}

	.right-scroll {
		width: 500rpx;
		height: 100%;
	}

	.one-box {
		width: 100%;
		font-size: 28rpx;
		height: 100rpx;
		justify-content: flex-start;
		padding: 0 20rpx
	}

	.sel-info {
		background: #fff;
	}
</style>